var xhr; // 비동기 서버 연동을 위한 객체
function createXMLHttpRequest(){
	if(window.ActiveXObject){//ms exploer 일 경우
		xhr=new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		xhr=new XMLHttpRequest();	
	}
}
//assetResuet_insert.jsp
//평가표 자동 계산 스크립트
function ciaSum(){
	var a_c=parseInt(document.getElementById("a_c").value);
	var a_i=parseInt(document.getElementById("a_i").value);
	var a_a=parseInt(document.getElementById("a_a").value);
	//var sum=parseFloat(a_c+a_i+a_a);
	var sum=a_c+a_i+a_a;
	//var jobScore=parseFloat(document.getElementById("job_score").value);
	//var assetScore=(jobScore*sum).toFixed(1);
	document.getElementById("cia_sum").value=sum;
	//document.getElementById("asset_score").value=assetScore;
	createXMLHttpRequest();
	xhr.onreadystatechange = ciaKindResult;
	xhr.open("POST","assetAction.do",true);
	xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=utf-8");
	//xhr.send("mode=ciaKind&assetScore="+assetScore);
	xhr.send("mode=ciaKind&sum="+sum);
}
function ciaKindResult(){
	if(xhr.readyState==4){
		if(xhr.status==200){
			var result=xhr.responseText;
			var jsonData=eval('('+result+')');
			if(jsonData.ciaKind=="N"){
				document.getElementById("cia_kind").value="";
			}else{
				document.getElementById("cia_kind").value=jsonData.ciaKind;
			}
		}
	}
}

//assetIdenty_insert.jsp
//자산코드 유효성 검사
var acdFlag="Y";
function searchAcd(acd){
	a_cd=acd.value;
	createXMLHttpRequest();
	xhr.onreadystatechange = searchAcdResult;
	xhr.open("POST","assetAction.do",true);
	xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
	xhr.send("mode=searchAcd&a_cd="+a_cd);
}
function searchAcdResult(){
	if(xhr.readyState==4){
		if(xhr.status==200){
			var result=xhr.responseText;
			var jsonData=eval('('+result+')');
			 if(jsonData.a_cdFlag=="N"){
				 acdFlag="N";
			}else{
				acdFlag="Y";
			}
		}
	}
}

//pro_id저장(header.jsp)
function saveProId(obj){
	var proId=obj.value;
	createXMLHttpRequest();
	xhr.onreadystatechange = saveProIdResult;
	xhr.open("POST","projectAction.do",true);
	xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
	xhr.send("mode=saveProId&proId="+proId);
}
function saveProIdResult(){
	if(xhr.readyState==4){
		if(xhr.status==200){
			var result=xhr.responseText;
			var jsonData=eval('('+result+')');
			window.location.reload(true);
		}
	}
}
